# This imports are Lymon's ones
from lymon.core import HTML, TagHTML
from lymon.tw import Site

# ToscaWidgets imports
from tw.api import Widget, WidgetsList
from tw.forms import TableForm
from tw.forms.fields import TextField, SubmitButton


__all__ = ['Page_1', 'Page_2']

# You can use ANY widget you want, here I'll create a few simple ones just to ilustrate'

# You should Goup the Widgets in WidgetsList to work in the Site widget ( You can remplace this widgets with any other)

# Widgets definitions, you can use Any widget you like
# Page 1 Widgets
class Release(WidgetsList):
	lymon = Widget(template='''<h4> Lymon CMS - Version 0.2-r27.</h4>''')
	owner = Widget(template='''<p> Copyright Laureano Arcanio - 2008. </p>''')
	License = Widget(template='''<p> Released under the MIT license.</p>''')
	
	
class TestForm(TableForm):
	class fields(WidgetsList):
		yourName = TextField(id='name', default = 'Jonhy')
		yourLastName = TextField(id='lastName', default = 'Le Bu') 

class FormSample(WidgetsList):
	formLaber = Widget(template='''<h4> This is a Sample Form Widget</h4>''')
	form = TestForm(action='/index')

# Page 2 Widgets
class TestForm_2(TableForm):
	class fields(WidgetsList):
		yourName = TextField(id='name', default = 'Jonhy')
		yourLastName = TextField(id='lastName', default = 'Le Bu') 
		yourJob = TextField(id='yourJob', default = 'Python Developer') 
		yourAdres = TextField(id='yourAdress', default = 'Av. Allways Live') 
		
class FormSample_2(WidgetsList):
	formLaber = Widget(template='''<h4> This is a Sample Form Widget </h4>''')
	form = TestForm_2(action='/index')
	
class Comments(WidgetsList):
	comment = Widget(template='''<p> This page adds a few widgets to page 1. Showing the inheritance mechanism. You should take a look under the ../sample/lymon/documents.py file to see how it's work's </p>''')


#########################################################################
# Lymon Stuff Here
# Documents definitions "Page_1 amd Page_2"
# Here whe declare the Document where we are going to publish our widgets

class Page_1(HTML):
	class tag01(TagHTML):
		slot = 'lymon.content.release'	
		# We instantiate the Release WidgetsList here
		group = Release()
		
	class tag02(TagHTML):
		slot = 'lymon.content.form'
		# The Tag, id and attributes can be mannually setted, or use __default__ (like tag01)
		tag = 'p' 		
		id = True
		attrs = {'class':'lymon_form'}		
		# We instantiate the Form WidgetsList here
		group = FormSample()
		
		
# Here we inherit from Page_1 Definition, and add Some other widgets
class Page_2(Page_1):
	class tag02(TagHTML):
		slot = 'lymon.content.form'
		tag = 'p' 		
		id = True
		attrs = {'class':'lymon_form'}		
		# We instantiate the Form WidgetsList here
		group = FormSample_2()
	class tag03(TagHTML):
		slot = 'lymon.content.comment'
		group = Comments()

# Page_1 and Page_2 are the Widget that we con instantiate and use in a TG Aplicattion
# You need to pass a document attribute

#page_1 = Site(document = Page_1())
#page_2 = Site(document = Page_2())
